
export default {
	setStateAttr(state, param) {
		if (param instanceof  Array) {
			for (let item  of param) {
				state[item.key] = item.val;
			}
		} else {
			state[param.key] = param.val;
		}
	},
	loginToken(state, token) {
		state.loginStatus = true
		state.token = token
		uni.setStorageSync('token', token)
	},
	// 登录
	login(state, user) {
		state.loginStatus = true
		state.user = user
		state.token = state.user.token
		
		uni.setStorageSync('user', JSON.stringify(user));
	},
	// 退出登录
	logout(state) {
		state.loginStatus = false
		state.user = {}
		state.token = false
		uni.removeStorageSync('user');
		uni.removeStorageSync('token');
	}
}